@@ -100,9 +100,16 @@ group :production do |
||
100 | 100 |
gem 'rack' |
101 | 101 |
end |
102 | 102 |
|
103 |
+# This hack needs some explanation. When on Heroku in production, use the pg, unicorn, and rails12factor gems. |
|
104 |
+# When not on Heroku, we still want our Gemfile.lock to include these gems, so we scope them to |
|
105 |
+# an unsupported platform. |
|
103 | 106 |
if ENV['ON_HEROKU'] || ENV['HEROKU_POSTGRESQL_ROSE_URL'] |
104 | 107 |
gem 'pg', group: :production |
105 |
- gem 'unicorn', groups: [:development, :production] |
|
108 |
+ gem 'unicorn', group: :production |
|
106 | 109 |
gem 'rails_12factor', group: :production |
110 |
+else |
|
111 |
+ gem 'pg', platform: :ruby_18 |
|
112 |
+ gem 'unicorn', platform: :ruby_18 |
|
113 |
+ gem 'rails_12factor', platform: :ruby_18 |
|
107 | 114 |
end |
108 | 115 |
|
@@ -161,6 +161,7 @@ GEM |
||
161 | 161 |
kaminari (0.16.1) |
162 | 162 |
actionpack (>= 3.0.0) |
163 | 163 |
activesupport (>= 3.0.0) |
164 |
+ kgio (2.9.2) |
|
164 | 165 |
kramdown (1.3.3) |
165 | 166 |
launchy (2.4.2) |
166 | 167 |
addressable (~> 2.3) |
@@ -192,6 +193,7 @@ GEM |
||
192 | 193 |
multi_xml (~> 0.5) |
193 | 194 |
rack (~> 1.2) |
194 | 195 |
orm_adapter (0.5.0) |
196 |
+ pg (0.17.1) |
|
195 | 197 |
polyglot (0.3.5) |
196 | 198 |
protected_attributes (1.0.8) |
197 | 199 |
activemodel (>= 4.0.1, < 5.0) |
@@ -214,11 +216,17 @@ GEM |
||
214 | 216 |
bundler (>= 1.3.0, < 2.0) |
215 | 217 |
railties (= 4.1.4) |
216 | 218 |
sprockets-rails (~> 2.0) |
219 |
+ rails_12factor (0.0.2) |
|
220 |
+ rails_serve_static_assets |
|
221 |
+ rails_stdout_logging |
|
222 |
+ rails_serve_static_assets (0.0.2) |
|
223 |
+ rails_stdout_logging (0.0.3) |
|
217 | 224 |
railties (4.1.4) |
218 | 225 |
actionpack (= 4.1.4) |
219 | 226 |
activesupport (= 4.1.4) |
220 | 227 |
rake (>= 0.8.7) |
221 | 228 |
thor (>= 0.18.1, < 2.0) |
229 |
+ raindrops (0.13.0) |
|
222 | 230 |
rake (10.3.2) |
223 | 231 |
ref (1.0.5) |
224 | 232 |
rest-client (1.6.7) |
@@ -317,6 +325,10 @@ GEM |
||
317 | 325 |
uglifier (2.5.1) |
318 | 326 |
execjs (>= 0.3.0) |
319 | 327 |
json (>= 1.8.0) |
328 |
+ unicorn (4.8.3) |
|
329 |
+ kgio (~> 2.6) |
|
330 |
+ rack |
|
331 |
+ raindrops (~> 0.7) |
|
320 | 332 |
uuid (2.3.7) |
321 | 333 |
macaddr (~> 1.0) |
322 | 334 |
uuidtools (2.1.4) |
@@ -374,11 +386,13 @@ DEPENDENCIES |
||
374 | 386 |
mqtt |
375 | 387 |
mysql2 (~> 0.3.16) |
376 | 388 |
nokogiri (~> 1.6.1) |
389 |
+ pg |
|
377 | 390 |
protected_attributes (~> 1.0.8) |
378 | 391 |
pry |
379 | 392 |
quiet_assets |
380 | 393 |
rack |
381 | 394 |
rails (= 4.1.4) |
395 |
+ rails_12factor |
|
382 | 396 |
rr |
383 | 397 |
rspec (~> 2.14) |
384 | 398 |
rspec-rails (~> 2.14) |
@@ -395,6 +409,7 @@ DEPENDENCIES |
||
395 | 409 |
typhoeus (~> 0.6.3) |
396 | 410 |
tzinfo-data |
397 | 411 |
uglifier (>= 1.3.0) |
412 |
+ unicorn |
|
398 | 413 |
vcr |
399 | 414 |
webmock (~> 1.17.4) |
400 | 415 |
weibo_2 (~> 0.1.4) |
@@ -32,21 +32,20 @@ def yes?(question) |
||
32 | 32 |
ask(question + " (y/n)") =~ /^y/i |
33 | 33 |
end |
34 | 34 |
|
35 |
-def grab_heroku_config |
|
35 |
+def grab_heroku_config! |
|
36 | 36 |
config_data = capture("heroku config -s") |
37 |
- config = {} |
|
37 |
+ $config = {} |
|
38 | 38 |
if config_data !~ /has no config vars/ |
39 | 39 |
config_data.split("\n").map do |line| |
40 | 40 |
next if line =~ /^\s*(#|$)/ # skip comments and empty lines |
41 | 41 |
first_equal_sign = line.index('=') |
42 |
- config[line.slice(0, first_equal_sign)] = line.slice(first_equal_sign + 1, line.length) |
|
42 |
+ $config[line.slice(0, first_equal_sign)] = line.slice(first_equal_sign + 1, line.length) |
|
43 | 43 |
end |
44 | 44 |
end |
45 |
- config |
|
46 | 45 |
end |
47 | 46 |
|
48 | 47 |
def set_value(key, value, options = {}) |
49 |
- unless config[key] == value |
|
48 |
+ unless $config[key] == value |
|
50 | 49 |
puts "Setting #{key} to #{value}" unless options[:silent] |
51 | 50 |
puts capture("heroku config:set #{key}=#{value}") |
52 | 51 |
end |
@@ -79,17 +78,17 @@ unless yes?("Your Heroku app name is #{app_name}. Is this correct?") |
||
79 | 78 |
puts "Well, then I'm not sure what to do here, sorry." |
80 | 79 |
end |
81 | 80 |
|
82 |
-config = grab_heroku_config |
|
81 |
+grab_heroku_config! |
|
83 | 82 |
|
84 |
-if config.length > 0 |
|
83 |
+if $config.length > 0 |
|
85 | 84 |
puts |
86 | 85 |
puts "Your current Heroku config:" |
87 |
- config.each do |key, value| |
|
86 |
+ $config.each do |key, value| |
|
88 | 87 |
puts ' ' + key + ' ' * (25 - [key.length, 25].min) + '= ' + value |
89 | 88 |
end |
90 | 89 |
end |
91 | 90 |
|
92 |
-unless config['APP_SECRET_TOKEN'] |
|
91 |
+unless $config['APP_SECRET_TOKEN'] |
|
93 | 92 |
puts "Setting up APP_SECRET_TOKEN..." |
94 | 93 |
puts capture("heroku config:set APP_SECRET_TOKEN=`rake secret`") |
95 | 94 |
end |
@@ -100,7 +99,7 @@ set_value 'ON_HEROKU', "true" |
||
100 | 99 |
set_value 'FORCE_SSL', "true" |
101 | 100 |
set_value 'DOMAIN', "#{app_name}.herokuapp.com" |
102 | 101 |
|
103 |
-unless config['INVITATION_CODE'] |
|
102 |
+unless $config['INVITATION_CODE'] |
|
104 | 103 |
puts "You need to set an invitation code for your Huginn instance. If you plan to share this instance, you will" |
105 | 104 |
puts "tell this code to anyone who you'd like to invite. If you won't share it, then just set this to something" |
106 | 105 |
puts "that people will not guess." |
@@ -109,7 +108,7 @@ unless config['INVITATION_CODE'] |
||
109 | 108 |
set_value 'INVITATION_CODE', invitation_code |
110 | 109 |
end |
111 | 110 |
|
112 |
-unless config['SMTP_DOMAIN'] && config['SMTP_USER_NAME'] && config['SMTP_PASSWORD'] && config['SMTP_SERVER'] && config['EMAIL_FROM_ADDRESS'] |
|
111 |
+unless $config['SMTP_DOMAIN'] && $config['SMTP_USER_NAME'] && $config['SMTP_PASSWORD'] && $config['SMTP_SERVER'] && $config['EMAIL_FROM_ADDRESS'] |
|
113 | 112 |
puts "Okay, let's setup outgoing email settings. The simplest solution is to use the free sendgrid Heroku addon." |
114 | 113 |
puts "If you'd like to use your own server, or your Gmail account, please see .env.example and set" |
115 | 114 |
puts "SMTP_DOMAIN, SMTP_USER_NAME, SMTP_PASSWORD, and SMTP_SERVER with 'heroku config:set'." |
@@ -119,14 +118,14 @@ unless config['SMTP_DOMAIN'] && config['SMTP_USER_NAME'] && config['SMTP_PASSWOR |
||
119 | 118 |
set_value 'SMTP_SERVER', "smtp.sendgrid.net", silent: true |
120 | 119 |
set_value 'SMTP_DOMAIN', "heroku.com", silent: true |
121 | 120 |
|
122 |
- config = grab_heroku_config |
|
123 |
- set_value 'SMTP_USER_NAME', config['SENDGRID_USERNAME'], silent: true |
|
124 |
- set_value 'SMTP_PASSWORD', config['SENDGRID_PASSWORD'], silent: true |
|
121 |
+ grab_heroku_config! |
|
122 |
+ set_value 'SMTP_USER_NAME', $config['SENDGRID_USERNAME'], silent: true |
|
123 |
+ set_value 'SMTP_PASSWORD', $config['SENDGRID_PASSWORD'], silent: true |
|
125 | 124 |
else |
126 | 125 |
puts "Okay, you'll need to set SMTP_DOMAIN, SMTP_USER_NAME, SMTP_PASSWORD, and SMTP_SERVER with 'heroku config:set' manually." |
127 | 126 |
end |
128 | 127 |
|
129 |
- unless config['EMAIL_FROM_ADDRESS'] |
|
128 |
+ unless $config['EMAIL_FROM_ADDRESS'] |
|
130 | 129 |
email = nag("What email address would you like email to appear to be sent from?") |
131 | 130 |
set_value 'EMAIL_FROM_ADDRESS', email |
132 | 131 |
end |